//
//  SignUpInformationViewController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/8/2.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "SignUpInformationViewController.h"
#import "OrderCommitCell.h"
#import "CommitOrderViewController.h"
#import "QQAndWechatShareView.h"
#import "UMSocialQQHandler.h"
#import "WXApi.h"
#import "AppDelegate.h"
#import "InstituSubmiteOverView.h"
@interface SignUpInformationViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UIScrollViewDelegate>{
    NSInteger totalNumber;
    AppDelegate *appdelegate;
}

@property(nonatomic,strong)UICollectionView *collectionView;

@property(nonatomic,strong)UICollectionViewFlowLayout *flowlayout;
@property (strong, nonatomic) NSMutableArray<CALayer *> *redLayers;


@property (strong, nonatomic)  UIImageView *shippingCartView;
@property (strong, nonatomic)  UILabel *numberLabel;

@property (strong, nonatomic)  UIView *bottomView;
@property(nonatomic,strong)UIButton *settleBtn;

/*新的报名详情的页面*/
@property(nonatomic,strong)UIScrollView *scrollView;

@property(nonatomic,strong)QQAndWechatShareView *shareView;
@property(nonatomic,strong)UIView *showView;
@property(nonatomic,strong)UIView *backView;
@property(nonatomic,strong)InstituSubmiteOverView *submitView;
@end

@implementation SignUpInformationViewController

- (NSMutableArray<CALayer *> *)redLayers {
    if (!_redLayers) {
        _redLayers = [NSMutableArray array];
    }
    return _redLayers;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setShareBtn];
    [self createNewPage];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    CGFloat offset = self.scrollView.contentOffset.y;
    [self.navigationController.navigationBar
     setBackgroundImage:[self imageWithColor:[UIColor colorWithRed:255/255.0 green:201/255.0 blue:31/255.0 alpha:(offset / 64)>0.99?0.99:(offset / 64)]] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar
     setShadowImage:[UIImage new]];
}
-(UIImage*) imageWithColor:(UIColor*) color
{
    CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
    
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = nil;
}
-(void)setShareBtn{
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [shareBtn setBackgroundImage:[UIImage imageNamed:@"upProductShare"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(showShareUI) forControlEvents:UIControlEventTouchUpInside];
    shareBtn.frame = CGRectMake(WIDTH - 30, 6, 20, 20);
    UIBarButtonItem *flexSpac = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
    flexSpac.width = -10;
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
    self.navigationItem.rightBarButtonItems = @[flexSpac,rightItem];
}
-(void)showShareUI{
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.alpha = 0.5f;
    backView.backgroundColor = [UIColor blackColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removebackView:)];
    [backView addGestureRecognizer:tap];
    [[UIApplication sharedApplication].keyWindow addSubview:backView];
    _shareView = [[QQAndWechatShareView alloc] initWithFrame:CGRectMake(0, HEIGHT, WIDTH, scaleTopAndBottom(94))];
    [_shareView.QQBtn addTarget:self action:@selector(QQShare:) forControlEvents:UIControlEventTouchUpInside];
    [_shareView.WechatBtn addTarget:self action:@selector(WechatShare:) forControlEvents:UIControlEventTouchUpInside];
    [[UIApplication sharedApplication].keyWindow addSubview:_shareView];
    [UIView animateWithDuration:0.1 animations:^{
        _shareView.frame = CGRectMake(0,HEIGHT - scaleTopAndBottom(94), WIDTH, scaleTopAndBottom(94));
    }];
}
-(void)WechatShare:(UIButton *)btn{
    /** 标题
     * @note 长度不能超过512字节
     */
    // @property (nonatomic, retain) NSString *title;
    /** 描述内容
     * @note 长度不能超过1K
     */
    //@property (nonatomic, retain) NSString *description;
    /** 缩略图数据
     * @note 大小不能超过32K
     */
    //  @property (nonatomic, retain) NSData   *thumbData;
    /**
     * @note 长度不能超过64字节
     */
    // @property (nonatomic, retain) NSString *mediaTagName;
    /**
     * 多媒体数据对象，可以为WXImageObject，WXMusicObject，WXVideoObject，WXWebpageObject等。
     */
    // @property (nonatomic, retain) id        mediaObject;
    
    /*! @brief 设置消息缩略图的方法
     *
     * @param image 缩略图
     * @note 大小不能超过32K
     */
    //- (void) setThumbImage:(UIImage *)image;
    //缩略图
    UIImage *image = [UIImage imageNamed:@"LOGO4"];
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = @"咱俩铁吗?铁就投我一票!";
    message.description = @"我在途吉打比赛,小伙伴等待你的一票啊！多谢啦！";
    //png图片压缩成data的方法，如果是jpg就要用 UIImageJPEGRepresentation
    message.thumbData = UIImagePNGRepresentation(image);
    [message setThumbImage:image];
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = [NSString stringWithFormat:@"%@/h5/canvass?id=%@",ServerIp,self.matchRecordId];
    message.mediaObject = ext;
    message.mediaTagName = @"ISOFTEN_TAG_JUMP_SHOWRANK";
    
    SendMessageToWXReq *sentMsg = [[SendMessageToWXReq alloc]init];
    sentMsg.message = message;
    sentMsg.bText = NO;
    sentMsg.scene =  WXSceneSession;
    //    //选择发送到会话(WXSceneSession)或者朋友圈(WXSceneTimeline)
    //    if (isPengyouquan) {
    //        sentMsg.scene = WXSceneTimeline;  //分享到朋友圈
    //    }else{
    //        sentMsg.scene =  WXSceneSession;  //分享到会话。
    //    }
    
    //如果我们想要监听是否成功分享，我们就要去appdelegate里面 找到他的回调方法
    // -(void) onResp:(BaseResp*)resp .我们可以自定义一个代理方法，然后把分享的结果返回回来。
    appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    //添加对appdelgate的微信分享的代理
    //    appdelegate.wxDelegate = self;
    BOOL isSuccess = [WXApi sendReq:sentMsg];
}
-(void)QQShare:(UIButton *)btn{
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    
    //创建网页内容对象
    NSString* thumbURL =  @"http://www.tj698.com/resource/img/logo.png";
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"咱俩铁吗?铁就投我一票!" descr:@"我在途吉打比赛,小伙伴等待你的一票啊！多谢啦！" thumImage:thumbURL];
    //设置网页地址
    
    shareObject.webpageUrl = [NSString stringWithFormat:@"%@/h5/canvass?id=%@",ServerIp,self.matchRecordId];
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_QQ messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
                
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
        }
    }];
    
}
-(void)removebackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
        UIView *view = tap.view;
        [view removeFromSuperview];
        [_shareView removeFromSuperview];
    }];
}

/**
 创建新的页面
 */
-(void)createNewPage{
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    self.scrollView.delegate = self;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.scrollView];
    self.scrollView.contentSize = CGSizeMake(WIDTH, scaleTopAndBottom(966));
    UIView *faterVeiw = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, scaleTopAndBottom(966))];
    faterVeiw.backgroundColor = COLOR_HEX(0xf4f5f6);
    [self.scrollView addSubview:faterVeiw];
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, scaleTopAndBottom(275))];
    [faterVeiw addSubview:topView];
    topView.backgroundColor  = COLOR_HEX(0xFFC91F);
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:topView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(18, 18)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = topView.bounds;
    maskLayer.path = maskPath.CGPath;
    topView.layer.mask = maskLayer;
    
    UIImageView *overImageView = [[UIImageView alloc] init];
    overImageView.image = [UIImage imageNamed:@"图层15"];
    [topView addSubview:overImageView];
    [overImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_top).offset(64);
        make.centerX.equalTo(topView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(37), scaleTopAndBottom(37)));
    }];
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"参赛成功！ 距离比赛结束还有";
    titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18];
    if (WIDTH > 375.f) {
            titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:27];
    }
    if (WIDTH < 375.f) {
        titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12];
    }
    titleLabel.textColor = [UIColor whiteColor];
    [topView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(topView.mas_centerX);
        make.top.equalTo(overImageView.mas_bottom).offset(scaleTopAndBottom(10));
        make.width.mas_equalTo(WIDTH);
        make.height.mas_equalTo(scaleTopAndBottom(20));
    }];
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.textColor = [UIColor whiteColor];
    timeLabel.textAlignment = NSTextAlignmentCenter;
    timeLabel.font = [UIFont systemFontOfSize:15];
//    timeLabel.text = @"30天14小时29分";
    timeLabel.text = [self getHour:@"" systemTime:self.matchStartTime];
    [self.view addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(8);
        make.left.and.right.equalTo(self.view);
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [backBtn addTarget:self action:@selector(backCenterPageView:) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setTitle:@"返回首页" forState:UIControlStateNormal];
    [backBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    backBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    backBtn.layer.borderWidth = 0.5;
    [topView addSubview:backBtn];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(topView.mas_centerX);
        make.top.equalTo(timeLabel.mas_bottom).offset(scaleTopAndBottom(19));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(85), scaleTopAndBottom(30)));
    }];
    UIView *centerView = [[UIView alloc] init];
    centerView.backgroundColor = [UIColor whiteColor];
    [faterVeiw addSubview:centerView];
    [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(faterVeiw.mas_left).offset(scaleLeftAndRight(10));
        make.centerX.equalTo(faterVeiw.mas_centerX);
        make.top.equalTo(topView.mas_bottom).offset(scaleTopAndBottom(-60));
        make.height.mas_equalTo(scaleTopAndBottom(705));
    }];
    UILabel *centerViewTitleLabel = [[UILabel alloc] init];
    centerViewTitleLabel.textAlignment = NSTextAlignmentCenter;
    centerViewTitleLabel.text = @"赛事主题";
    centerViewTitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:16];
    if (WIDTH > 375.0f) {
            centerViewTitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:24];
    }
    if (WIDTH < 375.f) {
         centerViewTitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:11];
    }
    centerViewTitleLabel.textColor = COLOR_HEX(0x121212);
    [centerView addSubview:centerViewTitleLabel];
    [centerViewTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(centerView.mas_top).offset(scaleTopAndBottom(22));
        make.centerX.equalTo(centerView.mas_centerX);
        make.width.mas_equalTo(WIDTH);
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UILabel *productLabel = [[UILabel alloc] init];
    productLabel.textAlignment = NSTextAlignmentCenter;
    productLabel.text = @"仰望中国上海最高处";
    productLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
    if (WIDTH > 375.f) {
            productLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:23];
    }
    if (WIDTH < 375.f) {
                    productLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:10];
    }
    productLabel.textColor = COLOR_HEX(0x666666);
    [centerView addSubview:productLabel];
    [productLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(centerView.mas_centerX);
        make.top.equalTo(centerViewTitleLabel.mas_bottom).offset(scaleTopAndBottom(12));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIImageView *leftImageView = [[UIImageView alloc] init];
    leftImageView.image = [UIImage imageNamed:@"椭圆1"];
    [centerView addSubview:leftImageView];
    [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(productLabel.mas_left).offset(scaleLeftAndRight(-9));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(17), scaleTopAndBottom(4)));
        make.centerY.mas_equalTo(productLabel.mas_centerY);
    }];
    leftImageView.transform = CGAffineTransformMakeRotation(M_PI);
    UIImageView *rightImageView = [[UIImageView alloc] init];
    rightImageView.image = [UIImage imageNamed:@"椭圆1"];
    [centerView addSubview:rightImageView];
    [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(productLabel.mas_right).offset(scaleLeftAndRight(9));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(17), scaleTopAndBottom(4)));
        make.centerY.mas_equalTo(productLabel.mas_centerY);
    }];
    UIImageView *lineImageView = [[UIImageView alloc] init];
    [centerView addSubview:lineImageView];
    [lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(centerView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(248), scaleTopAndBottom(1)));
        make.top.equalTo(productLabel.mas_bottom).offset(scaleTopAndBottom(20));
    }];
    UIImageView *bgImageView = [[UIImageView alloc] init];
    [centerView addSubview:bgImageView];
    bgImageView.image = [UIImage imageNamed:@"phtoBg"];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineImageView.mas_bottom).offset(scaleTopAndBottom(20));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(265), scaleTopAndBottom(317)));
        make.centerX.equalTo(centerView.mas_centerX).offset(scaleLeftAndRight(20));
    }];
    UIImageView *productView = [[UIImageView alloc] init];
    productView.image = self.productImage;
    [bgImageView addSubview:productView];
    [productView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(160), scaleTopAndBottom(220)));
        make.left.equalTo(bgImageView.mas_left).offset(32.5);
        make.top.equalTo(bgImageView.mas_top).offset(34.5);
    }];
    UIImageView *banyuanView = [[UIImageView alloc] init];
//    banyuanView.image = [UIImage imageNamed:@"图层18"];
    [centerView addSubview:banyuanView];
    [banyuanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgImageView.mas_bottom).offset(scaleTopAndBottom(15));
        make.centerX.equalTo(centerView.mas_centerX);
        make.left.equalTo(centerView.mas_left);
        make.height.mas_equalTo(scaleTopAndBottom(48));
    }];
    UIView *leftBanyuanView = [[UIView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(-24), 0, scaleLeftAndRight(48), scaleTopAndBottom(48))];
    leftBanyuanView.backgroundColor = COLOR_HEX(0xf3f4f5);
    [banyuanView addSubview:leftBanyuanView];
    [leftBanyuanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(48), scaleTopAndBottom(48)));
        make.centerX.equalTo(banyuanView.mas_left);
        make.top.equalTo(banyuanView.mas_top);
    }];
    leftBanyuanView.layer.cornerRadius = scaleTopAndBottom(24);
    leftBanyuanView.layer.masksToBounds = YES;
    
    UIView *rightBanyuanView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, scaleLeftAndRight(48), scaleTopAndBottom(48))];
    rightBanyuanView.backgroundColor = COLOR_HEX(0xf3f4f5);
    [banyuanView addSubview:rightBanyuanView];
    [rightBanyuanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(48), scaleTopAndBottom(48)));
        make.centerX.equalTo(banyuanView.mas_right);
        make.top.equalTo(banyuanView.mas_top);
    }];
    rightBanyuanView.layer.cornerRadius = scaleTopAndBottom(24);
    rightBanyuanView.layer.masksToBounds = YES;
    
    UIImageView *centerLineLabel = [[UIImageView alloc] init];
    centerLineLabel.image = [UIImage imageNamed:@"形状1"];
    [banyuanView addSubview:centerLineLabel];
    [centerLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(leftBanyuanView.mas_right).offset(scaleLeftAndRight(2));
        make.centerX.equalTo(banyuanView.mas_centerX);
        make.centerY.equalTo(banyuanView.mas_centerY);
        make.height.mas_equalTo(scaleTopAndBottom(1));
    }];
    [self drawDashLine:centerLineLabel lineLength:scaleTopAndBottom(1) lineSpacing:0.5 lineColor:[UIColor greenColor]];
    UILabel *autorProductLabel = [[UILabel alloc] init];
    autorProductLabel.text = @"作品名称";
    autorProductLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorProductLabel];
    [autorProductLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(banyuanView.mas_bottom).offset(scaleTopAndBottom(30)); make.left.equalTo(centerView.mas_left).offset(scaleLeftAndRight(25));
        make.width.mas_equalTo(scaleLeftAndRight(120));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    UILabel *autorProductLabel1 = [[UILabel alloc] init];
    autorProductLabel1.text = self.fileName;
    autorProductLabel1.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorProductLabel1];
    [autorProductLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(banyuanView.mas_bottom).offset(scaleTopAndBottom(30)); make.left.equalTo(autorProductLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    
    UILabel *autorNameLabel = [[UILabel alloc] init];
    autorNameLabel.text = @"宝宝姓名";
    autorNameLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorNameLabel];
    [autorNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorProductLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(centerView.mas_left).offset(scaleLeftAndRight(25));
        make.width.mas_equalTo(scaleLeftAndRight(120));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UILabel *autorNameLabel1 = [[UILabel alloc] init];
    autorNameLabel1.text = self.babyName;
    autorNameLabel1.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorNameLabel1];
    [autorNameLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorProductLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(autorNameLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
   
    UILabel *autorContactWayLabel = [[UILabel alloc] init];
    autorContactWayLabel.text = @"联系方式";
    autorContactWayLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorContactWayLabel];
    [autorContactWayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorNameLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(centerView.mas_left).offset(scaleLeftAndRight(25));
        make.width.mas_equalTo(scaleLeftAndRight(120));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    
    UILabel *autorContactWayLabel1 = [[UILabel alloc] init];
    autorContactWayLabel1.text = self.phoneNumber;
    autorContactWayLabel1.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorContactWayLabel1];
    [autorContactWayLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorNameLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(autorContactWayLabel.mas_right).offset(scaleLeftAndRight(30));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
   
    UILabel *autorAddressLabel = [[UILabel alloc] init];
    autorAddressLabel.text = self.addressStr;
    autorAddressLabel.numberOfLines = 0;
    autorAddressLabel.font = [UIFont systemFontOfSize:14];
    [centerView addSubview:autorAddressLabel];
    [autorAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorContactWayLabel.mas_bottom).offset(scaleTopAndBottom(15)); make.left.equalTo(autorContactWayLabel1.mas_left).offset(scaleLeftAndRight(0));
        make.right.equalTo(centerView.mas_right).offset(scaleLeftAndRight(-25));
        make.height.mas_equalTo(scaleTopAndBottom(30));
    }];
    UILabel * annotationLabel = [[UILabel alloc] init];
    annotationLabel.textColor = COLOR_HEX(0xFF5428);
    annotationLabel.font = [UIFont systemFontOfSize:12];
    annotationLabel.textAlignment = NSTextAlignmentCenter;
    annotationLabel.text = @"注释: 分享到第三方平台为作品投票，更容易获奖哦";
    [centerView addSubview:annotationLabel];
    [annotationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(autorAddressLabel.mas_bottom).offset(scaleTopAndBottom(30));
        make.centerX.equalTo(centerView.mas_centerX);
        make.height.mas_equalTo(scaleTopAndBottom(15));
        make.width.mas_equalTo(WIDTH);
    }];
    UILabel *lastBottomLabel = [[UILabel alloc] init];
    lastBottomLabel.text = @"我是有底线的";
    lastBottomLabel.textColor = COLOR_HEX(0xB2B2B2);
    lastBottomLabel.textAlignment = NSTextAlignmentCenter;
    lastBottomLabel.font = [UIFont systemFontOfSize:10];
    NSDictionary *dic = @{NSFontAttributeName : [UIFont systemFontOfSize:10.f]};
    CGSize labelSize = [lastBottomLabel.text boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:dic context:nil].size;
    [faterVeiw addSubview:lastBottomLabel];
    [lastBottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(faterVeiw.mas_centerX);
        make.bottom.equalTo(faterVeiw.mas_bottom).offset(scaleTopAndBottom(-17));
        make.top.equalTo(centerView.mas_bottom).offset(scaleTopAndBottom(17));
        make.width.mas_equalTo(scaleLeftAndRight(80));
    }];
    UIView *bottomLineLeftView = [[UIView alloc] init];
    bottomLineLeftView.backgroundColor = COLOR_HEX(0xDBDBDB);
    [faterVeiw addSubview:bottomLineLeftView];
    [bottomLineLeftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(faterVeiw.mas_left).offset(scaleLeftAndRight(41));
        make.centerY.equalTo(lastBottomLabel.mas_centerY);
        make.right.equalTo(lastBottomLabel.mas_left).offset(scaleLeftAndRight(0));
        make.height.mas_equalTo(1);
    }];
    UIView *bottomLineRightView = [[UIView alloc] init];
    bottomLineRightView.backgroundColor = COLOR_HEX(0xDBDBDB);
    [faterVeiw addSubview:bottomLineRightView];
    [bottomLineRightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(faterVeiw.mas_right).offset(scaleLeftAndRight(-41));
        make.centerY.equalTo(lastBottomLabel.mas_centerY);
        make.left.equalTo(lastBottomLabel.mas_right).offset(scaleLeftAndRight(0));
        make.height.mas_equalTo(1);
    }];
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        // Fallback on earlier versions
    }
    [self showRewardView];
}
-(void)backCenterPageView:(UIButton *)btn{
    NSLog(@"你想返回吗");
    NSArray *viewcontrollers = self.navigationController.viewControllers;
    if (viewcontrollers.count > 1) {
        if ([viewcontrollers objectAtIndex:viewcontrollers.count - 1] == self) {
            //push方式
            [self.navigationController popToRootViewControllerAnimated:YES];
        }
    }
    else{
        //present方式
        [self dismissViewControllerAnimated:YES completion:nil];
    }
//    [self.navigationController popToRootViewControllerAnimated:YES];
}
-(void)showRewardView{
    
    self.backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.backView.alpha = 0.5f;
    self.backView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.backView];
    self.submitView = [[InstituSubmiteOverView alloc] initWithFrame:CGRectZero];
    _submitView.imageV.image = [UIImage imageNamed:@"组1"];
    [self.view addSubview:_submitView];
    [_submitView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(0, 0));
    }];
    [UIView animateWithDuration:1.0f animations:^{
        [_submitView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(305), scaleTopAndBottom(300)));
        }];
        
    }];
    
    UITapGestureRecognizer *tapdd = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removessbackView:)];
    UIView *deletedView = [[UIView alloc] init];
    [_submitView addSubview:deletedView];
    [deletedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_submitView.mas_centerX);
        make.bottom.equalTo(_submitView.mas_bottom).offset(scaleTopAndBottom(0));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(24), scaleTopAndBottom(24)));
    }];
    [deletedView addGestureRecognizer:tapdd];
    
    UITapGestureRecognizer *tapss = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapViewToSure:)];
    UIView *sureView = [[UIView alloc] init];
    [_submitView addSubview:sureView];
    [sureView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(172), scaleTopAndBottom(37)));
        make.centerX.mas_equalTo(_submitView.mas_centerX);
        make.bottom.equalTo(deletedView.mas_top).offset(scaleTopAndBottom(-42));
    }];
    [sureView addGestureRecognizer:tapss];
}
-(void)tapViewToSure:(UITapGestureRecognizer *)tap{
    [UIView animateWithDuration:0.1 animations:^{
        //        UIView *view = tap.view;
        [self.backView removeFromSuperview];
        [_submitView removeFromSuperview];
    }];
    NSLog(@"你点击了确定的部分");
    [self showShareUI];
}
-(void)removessbackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
        //        UIView *view = tap.view;
        [self.backView removeFromSuperview];
        [_submitView removeFromSuperview];
    }];
}
- (void)drawDashLine:(UIView *)lineView lineLength:(int)lineLength lineSpacing:(int)lineSpacing lineColor:(UIColor *)lineColor
{
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:lineView.bounds];
    [shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame) / 2, CGRectGetHeight(lineView.frame))];
    [shapeLayer setFillColor:[UIColor clearColor].CGColor];
    //  设置虚线颜色为blackColor
    [shapeLayer setStrokeColor:lineColor.CGColor];
    //  设置虚线宽度
    [shapeLayer setLineWidth:CGRectGetHeight(lineView.frame)];
    [shapeLayer setLineJoin:kCALineJoinRound];
    //  设置线宽，线间距
    [shapeLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:lineLength], [NSNumber numberWithInt:lineSpacing], nil]];
    //  设置路径
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 0, 0);
    CGPathAddLineToPoint(path, NULL, CGRectGetWidth(lineView.frame), 0);
    [shapeLayer setPath:path];
    CGPathRelease(path);
    //  把绘制好的虚线添加上来
    [lineView.layer addSublayer:shapeLayer];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat offset = self.scrollView.contentOffset.y;
    [self.navigationController.navigationBar
     setBackgroundImage:[self imageWithColor:[UIColor colorWithRed:255/255.0 green:201/255.0 blue:31/255.0 alpha:(offset / 64)>0.99?0.99:(offset / 64)]] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar
     setShadowImage:[UIImage new]];
}
///*
//-(void)createTopUI{
//    self.view.backgroundColor = [UIColor whiteColor];
//    UILabel *titleLabel = [[UILabel alloc] init];
//    titleLabel.text = @"报名成功!距离比赛还有";
//    titleLabel.textColor = [UIColor lightGrayColor];
//    titleLabel.textAlignment = NSTextAlignmentCenter;
//    [self.view addSubview:titleLabel];
//    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.view.mas_top).offset(84);
//        make.left.and.right.equalTo(self.view);
//        make.height.mas_equalTo(scaleTopAndBottom(20));
//    }];
//    UILabel *timeLabel = [[UILabel alloc] init];
//    timeLabel.textColor = [UIColor lightGrayColor];
//    timeLabel.textAlignment = NSTextAlignmentCenter;
//    timeLabel.font = [UIFont systemFontOfSize:14];
//    timeLabel.text = [self getHour:@"" systemTime:self.matchStartTime];
//    [self.view addSubview:timeLabel];
//    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(titleLabel.mas_bottom).offset(10);
//        make.left.and.right.equalTo(self.view);
//        make.height.mas_equalTo(scaleTopAndBottom(15));
//    }];
//    UIImageView *bgimageView = [[UIImageView alloc] init];
//    bgimageView.image = [UIImage imageNamed:@"signDetail"];
//    [self.view addSubview:bgimageView];
//    [bgimageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(timeLabel.mas_bottom).offset(scaleTopAndBottom(20));
//        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(15));
//        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-15));
//        make.height.mas_equalTo(scaleTopAndBottom(220));
//    }];
//    UILabel *bgtitleLabel = [[UILabel alloc] init];
//    bgtitleLabel.text = @"您的参赛主题";
//    bgtitleLabel.textColor = COLOR_HEX(0x6C6C74);
//    bgtitleLabel.font = [UIFont systemFontOfSize:13];
//    bgtitleLabel.textAlignment = NSTextAlignmentCenter;
//    [bgimageView addSubview:bgtitleLabel];
//    [bgtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(bgimageView.mas_top).offset(scaleTopAndBottom(15));
//        make.left.and.right.equalTo(bgimageView);
//        make.height.mas_equalTo(scaleTopAndBottom(20));
//    }];
//    UIImageView *leftView = [[UIImageView alloc] init];
//    [bgimageView addSubview:leftView];
//    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(bgimageView.mas_left).offset(scaleLeftAndRight(50));
//        make.top.equalTo(bgtitleLabel.mas_bottom).offset(scaleTopAndBottom(15));
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
//    UIImageView *rightView = [[UIImageView alloc] init];
//    [bgimageView addSubview:rightView];
//    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.equalTo(bgimageView.mas_right).offset(scaleLeftAndRight(-50));
//        make.top.equalTo(bgtitleLabel.mas_bottom).offset(scaleTopAndBottom(15));
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
//    leftView.image = [UIImage imageNamed:@"图层-14"];
//    rightView.image = [UIImage imageNamed:@"图层-14"];
//    UILabel *themeleLabel = [[UILabel alloc] init];
//    themeleLabel.text = self.fileName;
//    themeleLabel.text = @"中国梦";
//    themeleLabel.font = [UIFont systemFontOfSize:19.0f];
//    themeleLabel.textAlignment = NSTextAlignmentCenter;
//    [bgimageView addSubview:themeleLabel];
//    [themeleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(bgtitleLabel.mas_bottom).offset(scaleTopAndBottom(5));
//        make.left.equalTo(leftView.mas_right).offset(scaleLeftAndRight(0));
//        make.right.equalTo(rightView.mas_left).offset(scaleLeftAndRight(0));
//        make.height.mas_equalTo(scaleTopAndBottom(30));
//    }];
///********************************横线的上半部分****************************/
//    UIView *lineView = [[UIView alloc] init];
//    [bgimageView addSubview:lineView];
//        lineView.backgroundColor = [UIColor lightGrayColor];
//    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(bgimageView.mas_left).offset(scaleLeftAndRight(20));
//        make.centerY.equalTo(bgimageView.mas_centerY);
//        make.right.equalTo(bgimageView.mas_right).offset(scaleLeftAndRight(-20));
//        make.height.mas_equalTo(0.5);
//
//    }];
///********************************横线的下半部分****************************/
//    UILabel *nameleLabel = [[UILabel alloc] init];
//    nameleLabel.font = [UIFont systemFontOfSize:13];
//    nameleLabel.textColor = COLOR_HEX(0x000008);
//    nameleLabel.textAlignment = NSTextAlignmentCenter;
//    nameleLabel.attributedText = [self CreateTextLabelAttributeText:@"宝宝姓名    " WithDetailInfor:self.babyName];
//    [bgimageView addSubview:nameleLabel];
//    [nameleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(lineView.mas_bottom).offset(scaleTopAndBottom(20));
//         make.centerX.equalTo(bgimageView.mas_centerX);
//        make.right.equalTo(bgimageView.mas_right).offset(scaleLeftAndRight(0));
//    }];
//    UILabel *productleLabel = [[UILabel alloc] init];
//    productleLabel.font = [UIFont systemFontOfSize:13];
//    productleLabel.textColor = COLOR_HEX(0x000008);
//    productleLabel.textAlignment = NSTextAlignmentCenter;
//    productleLabel.attributedText = [self CreateTextLabelAttributeText:@"作品名称    " WithDetailInfor:self.fileName];
//
//    [bgimageView addSubview:productleLabel];
//    [productleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(nameleLabel.mas_bottom).offset(scaleTopAndBottom(5));
//        make.centerX.equalTo(bgimageView.mas_centerX);
//        make.right.equalTo(bgimageView.mas_right).offset(scaleLeftAndRight(0));
//    }];
//    UILabel *phoneLabel = [[UILabel alloc] init];
//    phoneLabel.textAlignment = NSTextAlignmentCenter;
//    phoneLabel.font = [UIFont systemFontOfSize:13];
//    phoneLabel.textColor = COLOR_HEX(0x000008);
//    phoneLabel.attributedText = [self CreateTextLabelAttributeText:@"手机号码    " WithDetailInfor:self.phoneNumber];
//    [bgimageView addSubview:phoneLabel];
//    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(productleLabel.mas_bottom).offset(scaleTopAndBottom(5));
//        make.centerX.mas_equalTo(bgimageView.mas_centerX);
//        make.right.equalTo(bgimageView.mas_right).offset(scaleLeftAndRight(0));
//        make.bottom.equalTo(bgimageView.mas_bottom).offset(scaleTopAndBottom(-20));
//        make.height.equalTo(@[productleLabel,nameleLabel]);
//    }];
////    bgtitleLabel.backgroundColor = [UIColor redColor];
////    leftView.backgroundColor = [UIColor redColor];
////    rightView.backgroundColor = [UIColor redColor];
////    themeleLabel.backgroundColor = [UIColor greenColor];
//
////    bgimageView.backgroundColor = [UIColor orangeColor];
//
//
////    [self createCollectionView:bgimageView];
//}
//-(void)createCollectionView:(UIImageView *)imageview{
//    self.flowlayout = [[UICollectionViewFlowLayout alloc] init];
//    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowlayout];
//    self.collectionView.backgroundColor = [UIColor lightGrayColor];
//    [self.view addSubview:self.collectionView];
//    self.flowlayout.itemSize = CGSizeMake(scaleLeftAndRight(187), scaleTopAndBottom(230));
//    self.flowlayout.minimumLineSpacing = 1;
//    self.flowlayout.minimumInteritemSpacing = 1;
//    self.collectionView.dataSource = self;
//    self.collectionView.delegate = self;
//    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(imageview.mas_bottom).offset(scaleTopAndBottom(10));
//        make.left.and.right.equalTo(self.view);
//        make.bottom.equalTo(self.view.mas_bottom).offset(scaleTopAndBottom(-45));
//    }];
//    [self.collectionView registerClass:[OrderCommitCell class] forCellWithReuseIdentifier:@"OrderCommitCell"];
//    [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"informHeader"];
//    self.bottomView = [[UIView alloc] init];
//    [self.view addSubview:_bottomView];
//    _bottomView.backgroundColor = [UIColor purpleColor];
//    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.collectionView.mas_bottom);
//        make.left.and.right.equalTo(self.view);
//        make.bottom.equalTo(self.view.mas_bottom);
//    }];
//    self.shippingCartView = [[UIImageView alloc] init];
//    self.shippingCartView.image = [UIImage imageNamed:@"购物车"];
//    [_bottomView addSubview:self.shippingCartView];
//    [self.shippingCartView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.bottomView.mas_left).offset(scaleLeftAndRight(10));
//       make.top.equalTo(self.bottomView.mas_top).offset(scaleLeftAndRight(10));
//        make.size.mas_equalTo(CGSizeMake(25, 25));
//    }];
//    self.numberLabel = [[UILabel alloc] init];
//    [_bottomView addSubview:self.numberLabel];
//    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.shippingCartView.mas_right).offset(scaleLeftAndRight(8));
//        make.centerY.equalTo(self.bottomView.mas_centerY);
//        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(144), scaleTopAndBottom(20)));
//    }];
//    self.settleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    self.settleBtn.backgroundColor = [UIColor orangeColor];
//    [self.settleBtn setTitle:@"提交订单" forState:UIControlStateNormal];
//    [self.settleBtn addTarget:self action:@selector(OrderInformationpage:) forControlEvents:UIControlEventTouchUpInside];
//    [_bottomView addSubview:self.settleBtn];
//    [self.settleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.and.bottom.equalTo(_bottomView);
//        make.right.equalTo(_bottomView.mas_right);
//        make.left.equalTo(self.numberLabel.mas_right);
//    }];
//}
//-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
//    return 1;
//}
//-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//    return 20;
//}
//-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
//    OrderCommitCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"OrderCommitCell" forIndexPath:indexPath];
//    [cell setPlusTapHandle:^(CGPoint position) {
//        totalNumber++;
//        [self updateNumberLabel];
//        CGPoint startPoint = [self.view convertPoint:position fromView:self.collectionView];
//        CGPoint endPoint = [self.view convertPoint:self.shippingCartView.center fromView:self.bottomView];
//        [self initCHLayerFromPoint:startPoint toPoint:endPoint];
//        //model add to array
//
//    }];
//
//    [cell setMinusTapHandle:^() {
//        totalNumber--;
//        [self updateNumberLabel];
//    }];
//
//    return cell;
//}
//-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
//    UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"informHeader" forIndexPath:indexPath];
//    view.backgroundColor = [UIColor whiteColor];
//    [self createHeaderViewAboutUI:@"赛事周边" AndAddSubviewToFatherview:view];
//    return view;
//}
////创建collectionview的头部视图
//-(UIView *)createHeaderViewAboutUI:(NSString *)headerTitle AndAddSubviewToFatherview:(UIView *)fatherView{
//    UIView *view = [[UIView alloc] init];
//    view.backgroundColor = [UIColor yellowColor];
//    [fatherView addSubview:view];
//    [view mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(fatherView.mas_centerY);
//        make.left.equalTo(fatherView.mas_left);
//        make.height.mas_equalTo(25);
//        make.width.mas_equalTo(scaleLeftAndRight(2));
//
//    }];
//    UILabel *lable = [[UILabel alloc] init];
//    [fatherView addSubview:lable];
//    lable.text = headerTitle;
//    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(view.mas_right).offset(scaleLeftAndRight(10));
//        make.top.equalTo(fatherView.mas_top);
//        make.bottom.equalTo(fatherView.mas_bottom);
//        make.right.equalTo(fatherView.mas_right).offset(scaleLeftAndRight(-10));
//    }];
//    UIView *bottomview = [[UIView alloc] init];
//    bottomview.backgroundColor = [UIColor lightGrayColor];
//    [fatherView addSubview:bottomview];
//    [bottomview mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.and.right.equalTo(fatherView);
//        make.height.mas_equalTo(1);
//        make.bottom.equalTo(fatherView.mas_bottom);
//    }];
//    return fatherView;
//
//}
//-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
//    return CGSizeMake(WIDTH, scaleTopAndBottom(50));
//}
//- (void)initCHLayerFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint {
//
//    CALayer *chLayer = [[CALayer alloc] init];
//    [self.redLayers addObject:chLayer];
//
//    chLayer.frame = CGRectMake(startPoint.x, startPoint.y, 15, 15);
//    chLayer.cornerRadius = CGRectGetWidth(chLayer.frame)/2.f;
//    chLayer.backgroundColor = [UIColor redColor].CGColor;
//    [self.view.layer addSublayer:chLayer];
//
//    CAKeyframeAnimation *CHAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
//
//    CGMutablePathRef path = CGPathCreateMutable();
//    CGPathMoveToPoint(path, NULL, startPoint.x, startPoint.y);
//    CGPathAddQuadCurveToPoint(path, NULL, endPoint.x, startPoint.y, endPoint.x, endPoint.y);
//
//    CHAnimation.path = path;
//    CHAnimation.removedOnCompletion = NO;
//    CHAnimation.fillMode = kCAFillModeBoth;
//    CHAnimation.duration = 0.5;
//    CHAnimation.delegate = self;
//
//    [chLayer addAnimation:CHAnimation forKey:nil];
//
//}
//
//-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
//    [self.redLayers[0] removeFromSuperlayer];
//    [self.redLayers removeObjectAtIndex:0];
//
//}
//
//- (void)updateNumberLabel{
//    NSString *totalNumberStr = [NSString stringWithFormat:@"共 %zd 件商品",totalNumber];
//    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:totalNumberStr];
//    [attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.f] range:NSMakeRange(1, attributedStr.length - 4)];
//    self.numberLabel.attributedText = attributedStr;
//}
//-(void)OrderInformationpage:(UIButton *)btn{
//    CommitOrderViewController *commitVc = [[CommitOrderViewController alloc] init];
//    [self.navigationController pushViewController:commitVc animated:YES];
//}
//*/
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 根据标准时间计算出时间差

 */
/**
 根据时间戳获取到时间差
 
 */
- (NSString* )getHour:(NSString *)takeCarTime systemTime:(NSString *)systemTime

{
    
    //  时区相差8个小时 加上这个时区即是北京时间
    
    NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
    
    NSInteger delta = [timeZone secondsFromGMT];
    
    NSDate *DRstartDate = [NSDate date];
    NSDate *DRendDate = [[NSDate alloc] initWithTimeIntervalSince1970:[systemTime doubleValue]/1000 + delta];
    NSLog(@"开始时间%@",DRstartDate);
    NSLog(@"结束时间%@",DRendDate);
    // 日历对象 （方便比较两个日期之间的差距）
    
    NSTimeInterval interTime = [DRendDate timeIntervalSinceNow];
    //计算天数、时、分、秒
    
    int days = ((int)interTime)/(3600*24);
    
    int hours = ((int)interTime)%(3600*24)/3600;
    
    int minutes = ((int)interTime)%(3600*24)%3600/60;
    
    NSString *dateContent = [[NSString alloc] initWithFormat:@"倒计时:%i天%i时%i分",days,hours,minutes];
    NSLog(@"嘎嘎嘎嘎%@",dateContent);
    return dateContent;
    
}


/**
 创建富文本对象

 */
-(NSAttributedString *)CreateTextLabelAttributeText:(NSString *)text WithDetailInfor:(NSString *)content{
    NSMutableAttributedString * attrStr= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",text,content]];
    [attrStr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f],NSForegroundColorAttributeName:COLOR_HEX(0x77777E)} range:NSMakeRange(0, 4)];
//    [attrStr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13.0f],NSForegroundColorAttributeName:COLOR_HEX(0x000008)} range:NSMakeRange(5, attrStr.length - 1)];
    return attrStr;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
